<template>
	<view class="page"  :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<c-nav-bar :title="titleHeader" ></c-nav-bar>
		<view class="header">
			<view class="top">
				<span>起点：</span>
				<u-search shape="round" @tap="goToUrl()"></u-search>
				<span>取消</span>
			</view>
			<view class="bottom">
				<view class="left" @click="myPosition()">
					<image style="width: 32rpx; height: 32rpx;"
						src="https://i.ringzle.com/file/20231227/622999ce090e41caad249f40a93a14cc.png" mode="">
					</image>
					<span style="margin-left: 20rpx;">我的位置</span>
				</view>
			
				<!-- 	<view class="left" @click="myPosition()">
						<image style="width: 32rpx; height: 32rpx;"
							src="https://i.ringzle.com/file/20231227/622999ce090e41caad249f40a93a14cc.png" mode="">
						</image>
						<span style="margin-left: 20rpx;">我的位置</span>
					</view> -->
					<view class="left"  @click="goToUrl()">
						<image style="width: 32rpx; height: 32rpx;"
							src="https://i.ringzle.com/file/20231227/9569b454308a421ca44f34a9ce6aef74.png" mode="">
						</image>
						<span style="margin-left: 20rpx;">地图选点</span>
					</view>
			

			</view>
			<!-- <view class="main">
				<view class="title">
					搜索结果
				</view>
				<view class="main_contain">
					<view class="contain_left">
						<u-icon name="map-fill"></u-icon>
					</view>
					<view class="contain_right">
						<span style="font-weight: 700; margin-bottom: 10rpx;">嵊泗县人民政府</span>
						<span style='color: #717171;'>嵊泗县菜园镇沙河路348号</span>
					</view>
				</view>
			</view> -->
		</view>
	</view>

</template>

<script>
	var amapFile = require('@/utils/amap-wx.130.js');

	export default {

		data() {
			return {
				h:uni.getSystemInfoSync().windowHeight - 87,
				mt: uni.getSystemInfoSync().statusBarHeight + 44,
				titleHeader:'驿蓝租车',
				myaddress: '',
				longitude: '',
				latitude: ''
			}
		},
		mounted() {


		},
		methods: {
			goToUrl() {
				uni.navigateTo({
					url: '/pagesTaxi/Taxi/map'
				})
			},

			myPosition() {
				var myAmapFun = new amapFile.AMapWX({
					key: '4250d90eec4a2bcaaf9c4f486d2ad623'
				});
				let that = this;
				//获取地址
				myAmapFun.getRegeo({
					success: function(data) {
						that.myaddress = data[0].name
						that.longitude = data[0].longitude
						that.latitude = data[0].latitude
						// eventChannel().emit('addBeginPostionSuccess', {
						// 	myaddress: that.myaddress,
						// 	longitude: that.longitude,
						// 	latitude: that.latitude,
						// });
						const item = {
							mapOriginAddress: that.myaddress,
							mapOriginLatitude: that.longitude,
							mapOriginLongitude: that.latitude
						}
						uni.setStorageSync("beginSelected", item);
						uni.navigateTo({
							url: '/pagesTaxi/Taxi/orderWrite'
						})

					},
					fail: function(info) {
						//失败回调
						console.log(info)
						uni.navigateBack();
					}
				})



			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		// padding-top: 130rpx;
		.header {
			margin: 20rpx;
			border-bottom: 1rpx solid #e8e8e8;

			.top {
				margin: 20rpx;
				font-size: 29rpx;
				display: flex;
				align-items: center;
				justify-content: space-evenly;
			}

			.bottom {
				display: flex;

				.left {
					display: flex;
					justify-content: center;
					border-right: 1rpx solid #e8e8e8;
					width: 50%;
					text-align: center;
					margin: 20rpx;
				}

				.right {
					display: flex;
					justify-content: center;
					width: 50%;
					text-align: center;
					margin: 20rpx;
				}
			}
		}

		.main {
			padding: 0 20rpx;

			.title {
				margin: 20rpx 0;
				color: #757575;
				font-size: 26rpx;
			}

			&_contain {
				display: flex;
				padding: 20rpx;
				border-bottom: 1rpx solid #e8e8e8;

				.contain_left {
					margin: 20rpx;
				}

				.contain_right {
					display: flex;
					flex-direction: column;
				}
			}
		}
	}
</style>